define.template({
    type: 'View',
    commands: {
        'orgClick': {
            type: 'JS',
            text: 'var btnBar=VM(this).find("btnBar");for(var i=0;i<btnBar.length;i++){btnBar[i].disable(false);}' +
                'VM(this).fv("orgId",$0);VM(this).find("display").reload("user/list?orgId="+$0, "user/display");'
        },
        'edit': {
            type: 'Dialog',
            src: 'user/get?userId=$0&orgId=$1',
            template: 'user/form'
        },
        'search': {
            type: 'Submit',
            src: 'user/list?cp=$0',
            success: 'VM(this).find("display").reload($response,"user/display","table,pageBar");'
        },
        'delete': {
            type: 'Confirm',
            text: '是否删除所选记录?',
            yes: {
                type: 'Ajax',
                src: 'user/delete?userId=$0',
                success: 'this.cmd("search")'
            }
        }
    },
    node: {
        type: 'Horizontal',
        nodes: [
            {
                type: 'Tree',
                template: 'org/nav'
            },
            {
                type: 'Split',
                width: 10,
                movable: true,
                icon: '.i-split-right',
                expandedIcon: '.i-split-left',
                range: '0,400'
            },
            {
                type: 'Vertical',
                width: '*',
                nodes: [
                    {
                        type: 'ButtonBar',
                        id: 'btnBar',
                        align: 'right',
                        height: 40,
                        pub: {status: 'disabled'},
                        nodes: [
                            {
                                text: '新建', on: {
                                    click: 'this.cmd("edit","",VM(this).fv("orgId"))'
                                }
                            },
                            {type: 'SubmitButton', text: '查询', on: {click: 'this.cmd("search");'}},
                            {text: '删除', on: {click: 'this.cmd("delete",VM(this).fv("selectItem"))'}}]
                    },
                    {
                        type: 'Section',
                        id: 'display',
                        height: '*',
                        template: 'user/welcome'
                    }
                ]
            }
        ]
    }
});